

#include <string.h>
#include <ddk.h>
#include <zenr_api.h>
#include "vmodem.h"
#include "tapi_cmd.h"
#include "tapi_rsp.h"
#include "aciimp_rsp.h"
#include "tapi_ppp.h"
#include "tapierrs.h"
#include <_sprintf.h>


#define _VM_DEBUG 1

static VM_RESPONSEQUEUE s_generalResponseQueue;
static DzEvent s_generalResponseEvent(TRUE, UNSIGNALED);
//static DzMutex s_generalResponseLock;

static VM_INDICATORQUEUE s_indicatorQueue;
DzEvent g_indicatorEvent;

static Elastos::Int32 s_generalResponseQueueBusy = FALSE;
static Elastos::Int32 s_indicatorQueueBusy = FALSE;

extern volatile T_ACI_AT_CMD g_current_atcmd;
extern T_ACI_CMD_SRC g_ACICmdSrc;
extern int g_SyncTimeEnabled;
extern Elastos::UInt32 g_SyncTimeElapsed; 

extern unsigned long _GetElapsed();

#ifdef _VM_DEBUG
static void NU_LOG(const char *fmt, ...)
{
    nu_puts(fmt);
}
#endif /* _VM_DEBUG */

static void lockGeneralResponseQueue4Zener()
{
    while (InterlockedExchange(&s_generalResponseQueueBusy, TRUE)) {
        while (s_generalResponseQueueBusy) { DzSleep(1, NULL); }
    }
}

static void lockGeneralResponseQueue4Nucleus()
{
    while (InterlockedExchange(&s_generalResponseQueueBusy, TRUE)) {
        while (s_generalResponseQueueBusy) { nu_sleep(1); }
    }
}

static void unlockGeneralResponseQueue()
{
    InterlockedExchange(&s_generalResponseQueueBusy, FALSE);
}

static void lockIndicatorQueue4Zener()
{
    while (InterlockedExchange(&s_indicatorQueueBusy, TRUE)) {
        while (s_indicatorQueueBusy) { DzSleep(1, NULL); }
    }
}

static void lockIndicatorQueue4Nucleus()
{
    while (InterlockedExchange(&s_indicatorQueueBusy, TRUE)) {
        while (s_indicatorQueueBusy) { nu_sleep(1); }
    }
}

static void unlockIndicatorQueue()
{
    InterlockedExchange(&s_indicatorQueueBusy, FALSE);
}

static void addGeneralResponse(VM_RESPONSE_INTERNAL &response)
{
    lockGeneralResponseQueue4Nucleus();
    s_generalResponseQueue.AddTail(response);
    unlockGeneralResponseQueue();
    nu_notifyDeviceCaller((Uint32)&s_generalResponseEvent, 1);
}

static void addIndicator(VM_INDICATOR &ind)
{
    lockIndicatorQueue4Nucleus();
    s_indicatorQueue.AddTail(ind);
    unlockIndicatorQueue();
    nu_notifyDeviceCaller((Uint32)&g_indicatorEvent, 1);
}

VM_SYSTEM_STATUS g_VMStatus = {1, PB_STAT_Blocked};

void cleanResponseCache(T_ACI_AT_CMD cmdId)
{
    lockGeneralResponseQueue4Zener();
    POSITION ps = s_generalResponseQueue.GetHeadPosition();
    while (ps) {
        POSITION current = ps;
        VM_RESPONSE_INTERNAL &response = s_generalResponseQueue.GetNext(ps);
        if (response.cmdId == cmdId) {
            if (response.data.additional) {
                nu_getTapiPPP()->ip_free(response.data.additional);
            }
            s_generalResponseQueue.RemoveAt(current);
        }
    }
    unlockGeneralResponseQueue();
}

int getGeneralResponse(
    T_ACI_AT_CMD cmdId, int timeout, VM_RESPONSE *data, int *retType)
{
    int res = E_GEN_TIMEOUT;
    int_t to = DzMillisecondsToTicks(timeout);
    while (to > 0) {
        uint_t start = DzGetElapsedTicks();
        lockGeneralResponseQueue4Zener();
        int count = s_generalResponseQueue.GetCount();
        unlockGeneralResponseQueue();
        if (count == 0) {
            WaitResult wr;
            EventState stat;
            s_generalResponseEvent.Clear();
            s_generalResponseEvent.TryWait(to, &wr, &stat);
        }

        lockGeneralResponseQueue4Zener();

        POSITION ps = s_generalResponseQueue.GetHeadPosition();
        while (ps) {
            res = E_GEN_TIMEOUT;
            POSITION current = ps;
            VM_RESPONSE_INTERNAL &response =
                s_generalResponseQueue.GetNext(ps);
            if (cmdId == AT_CMD_COPS || AT_CMD_CRSM == cmdId) {
                if (response.cmdId == cmdId) {
                    if (response.type == VM_GR_OK) {
                        res = E_GEN_OK;
                    }
                    else if (response.type == VM_GR_CME) {
                        res = __MAKE_ATC_ECODE(__INFO_CME, response.data.value);
                    }
                    else if (response.type == VM_GR_CMS) {
                        res = __MAKE_ATC_ECODE(__INFO_CMS, response.data.value);
                    }
                    else if (response.type == VM_GR_COPS) {
                        if (response.data.additional == NULL) { break; }
                        if (data) {
                            struct VM_RSP_tAT_PlusCOPS *p =
                                (struct VM_RSP_tAT_PlusCOPS *)response.data.additional;
                            memcpy(&(data->tAT_PlusCOPS), p, sizeof(data->tAT_PlusCOPS));
                            res = E_GEN_OK;
                        }
                        else {
#ifdef _VM_DEBUG
                            NU_LOG("NU_LOG: WARN: VM_GR_COPS response is not fetched!\n");
#endif /* _VM_DEBUG */
                        }
                    }
                    else if (response.type == VM_GR_CRSM) {
                        if (response.data.additional == NULL) { break; }
                        if (data) {
                            struct VM_RSP_sAT_PlusCRSM *crsm =
                                (struct VM_RSP_sAT_PlusCRSM *)response.data.additional;
                            data->sAT_PlusCRSM.sw1 = crsm->sw1;
                            data->sAT_PlusCRSM.sw2 = crsm->sw2;
                            data->sAT_PlusCRSM.rspLen = crsm->rspLen;
                            memcpy(data->sAT_PlusCRSM.rsp, crsm->rsp, crsm->rspLen);
                            res = E_GEN_OK;
                        }
                        else {
#ifdef _VM_DEBUG
                            NU_LOG("NU_LOG: WARN: VM_GR_CRSM response is not fetched!\n");
#endif /* _VM_DEBUG */
                        }
                    }

                    if (res != E_GEN_TIMEOUT) {
                        if (retType) { *retType = response.type; }
                        if (response.data.additional) {
                            nu_getTapiPPP()->ip_free(response.data.additional);
                        }
                        s_generalResponseQueue.RemoveAt(current);
                        break;
                    }
                }
                if (response.cmdId == 0) {
                    if (response.data.additional) {
                        nu_getTapiPPP()->ip_free(response.data.additional);
                    }
                    s_generalResponseQueue.RemoveAt(current);
                }
            }
            else if (response.cmdId == cmdId || response.cmdId == 0) {
                if (response.type == VM_GR_OK) {
                    res = E_GEN_OK;
                }
                else if (response.type == VM_GR_CME) {
                    res = __MAKE_ATC_ECODE(__INFO_CME, response.data.value);
                }
                else if (response.type == VM_GR_CMS) {
                    res = __MAKE_ATC_ECODE(__INFO_CMS, response.data.value);
                }
                else if (response.type == VM_GR_CMGR) {
                    if (response.data.additional == NULL) { break; }
                    if (data) {
                        struct VM_RSP_sAT_PlusCMGR *cmgr =
                            (struct VM_RSP_sAT_PlusCMGR *)response.data.additional;
                        data->sAT_PlusCMGR.location = cmgr->location;
                        data->sAT_PlusCMGR.status = cmgr->status;
                        data->sAT_PlusCMGR.index = cmgr->index;
                        memcpy(data->sAT_PlusCMGR.pdu, cmgr->pdu, cmgr->len);
                        data->sAT_PlusCMGR.len = cmgr->len;
                        res = E_GEN_OK;
                    }
                    else {
#ifdef _VM_DEBUG
                        NU_LOG("NU_LOG: WARN: VM_GR_CMGR response is not fetched!\n");
#endif /* _VM_DEBUG */
                    }
                }
                else if (response.type == VM_GR_CMGS) {
                    if (data) {
                        data->sAT_PlusCMGS.mr = response.data.value;
                        res = E_GEN_OK;
                    }
                    else {
#ifdef _VM_DEBUG
                        NU_LOG("NU_LOG: WARN: VM_GR_CMGS response is not fetched!\n");
#endif /* _VM_DEBUG */
                    }
                }
                else if (response.type == VM_GR_CPMS) {
                    if (data) {
                        data->qAT_PlusCPMS.used = response.data.value >> 16;
                        data->qAT_PlusCPMS.total = response.data.value & 0xFFFF;
                        res = E_GEN_OK;
                    }
                    else {
#ifdef _VM_DEBUG
                        NU_LOG("NU_LOG: WARN: VM_GR_CPMS response is not fetched!\n");
#endif /* _VM_DEBUG */
                    }
                }
                else if (response.type == VM_GR_CSIM) {
                    if (response.data.additional == NULL) { break; }
                    if (data) {
                        struct VM_RSP_sAT_PlusCSIM *csim =
                            (struct VM_RSP_sAT_PlusCSIM *)response.data.additional;
                        data->sAT_PlusCSIM.rspLen = csim->rspLen;
                        memcpy(data->sAT_PlusCSIM.rsp, csim->rsp, csim->rspLen);
                        res = E_GEN_OK;
                    }
                    else {
#ifdef _VM_DEBUG
                        NU_LOG("NU_LOG: WARN: VM_GR_CSIM response is not fetched!\n");
#endif /* _VM_DEBUG */
                    }
                }
                else if (response.type == VM_GR_CMGW) {
                    if (response.data.additional == NULL) { break; }
                    if (data) {
                        struct VM_RSP_sAT_PlusCMGW *cmgw =
                            (struct VM_RSP_sAT_PlusCMGW *)response.data.additional;
                        data->sAT_PlusCMGW.index = cmgw->index;
                        data->sAT_PlusCMGW.numSeg = cmgw->numSeg;
                        res = E_GEN_OK;
                    }
                    else {
#ifdef _VM_DEBUG
                        NU_LOG("NU_LOG: WARN: VM_GR_CMGW response is not fetched!\n");
#endif /* _VM_DEBUG */
                    }
                }
                else if (response.type == VM_GR_CCWA) {
                    if (response.data.additional == NULL) { break; }
                    if (data) {
                        struct VM_RSP_qAT_PlusCCWA *p =
                            (struct VM_RSP_qAT_PlusCCWA *)response.data.additional;
                        data->qAT_PlusCCWA.status = p->status;
                        data->qAT_PlusCCWA.class_type = p->class_type;
                        res = E_GEN_OK;
                    }
                    else {
#ifdef _VM_DEBUG
                        NU_LOG("NU_LOG: WARN: VM_GR_CCWA response is not fetched!\n");
#endif /* _VM_DEBUG */
                    }
                }
                else if (response.type == VM_GR_CLIR) {
                    if (response.data.additional == NULL) { break; }
                    if (data) {
                        struct VM_RSP_qAT_PlusCLIR *p =
                            (struct VM_RSP_qAT_PlusCLIR *)response.data.additional;
                        data->qAT_PlusCLIR.mode = p->mode;
                        data->qAT_PlusCLIR.stat = p->stat;
                        res = E_GEN_OK;
                    }
                    else {
#ifdef _VM_DEBUG
                        NU_LOG("NU_LOG: WARN: VM_GR_CLIR response is not fetched!\n");
#endif /* _VM_DEBUG */
                    }
                }
                else if (response.type == VM_GR_CCFC) {
                    if (response.data.additional == NULL) { break; }
                    if (data) {
                        struct VM_RSP_qAT_PlusCCFC *p =
                            (struct VM_RSP_qAT_PlusCCFC *)response.data.additional;
                        memcpy(&(data->qAT_PlusCCFC), p, sizeof(data->qAT_PlusCCFC));
                        res = E_GEN_OK;
                    }
                    else {
#ifdef _VM_DEBUG
                        NU_LOG("NU_LOG: WARN: VM_GR_CCFC response is not fetched!\n");
#endif /* _VM_DEBUG */
                    }
                }
                else if (response.type == VM_GR_CLCK) {
                    if (response.data.additional == NULL) { break; }
                    if (data) {
                        struct VM_RSP_qAT_PlusCLCK *p =
                            (struct VM_RSP_qAT_PlusCLCK *)response.data.additional;
                        data->qAT_PlusCLCK.class_type = p->class_type;
                        data->qAT_PlusCLCK.status = p->status;
                        res = E_GEN_OK;
                    }
                    else {
#ifdef _VM_DEBUG
                        NU_LOG("NU_LOG: WARN: VM_GR_CLCK response is not fetched!\n");
#endif /* _VM_DEBUG */
                    }
                }
                else if (response.type == VM_GR_COPS) {
                    if (response.data.additional == NULL) { break; }
                    if (data) {
                        struct VM_RSP_tAT_PlusCOPS *p =
                            (struct VM_RSP_tAT_PlusCOPS *)response.data.additional;
                        memcpy(&(data->tAT_PlusCOPS), p, sizeof(data->tAT_PlusCOPS));
                        res = E_GEN_OK;
                    }
                    else {
#ifdef _VM_DEBUG
                        NU_LOG("NU_LOG: WARN: VM_GR_COPS response is not fetched!\n");
#endif /* _VM_DEBUG */
                    }
                }
                else if (response.type == VM_GR_CPOL) {
                    if (response.data.additional == NULL) { break; }
                    if (data) {
                        struct VM_RSP_qAT_PlusCPOL *p =
                            (struct VM_RSP_qAT_PlusCPOL *)response.data.additional;
                        memcpy(&(data->qAT_PlusCPOL), p, sizeof(data->qAT_PlusCPOL));
                        res = E_GEN_OK;
                    }
                    else {
#ifdef _VM_DEBUG
                        NU_LOG("NU_LOG: WARN: VM_GR_CPOL response is not fetched!\n");
#endif /* _VM_DEBUG */
                    }
                }
                else if (response.type == VM_GR_CRSM) {
                    if (response.data.additional == NULL) { break; }
                    if (data) {
                        struct VM_RSP_sAT_PlusCRSM *crsm =
                            (struct VM_RSP_sAT_PlusCRSM *)response.data.additional;
                        data->sAT_PlusCRSM.sw1 = crsm->sw1;
                        data->sAT_PlusCRSM.sw2 = crsm->sw2;
                        data->sAT_PlusCRSM.rspLen = crsm->rspLen;
                        memcpy(data->sAT_PlusCRSM.rsp, crsm->rsp, crsm->rspLen);
                        res = E_GEN_OK;
                    }
                    else {
#ifdef _VM_DEBUG
                        NU_LOG("NU_LOG: WARN: VM_GR_CRSM response is not fetched!\n");
#endif /* _VM_DEBUG */
                    }
                }
                else if (response.type == VM_GR_CPIN) {
                    if (response.data.additional == NULL) { break; }
                    if (data) {
                        struct VM_RSP_qAT_PlusCPIN *p =
                            (struct VM_RSP_qAT_PlusCPIN *)response.data.additional;
                        data->qAT_PlusCPIN.pin = p->pin;
                        res = E_GEN_OK;
                    }
                    else {
#ifdef _VM_DEBUG
                        NU_LOG("NU_LOG: WARN: VM_GR_CPIN response is not fetched!\n");
#endif /* _VM_DEBUG */
                    }
                }
                if (res != E_GEN_TIMEOUT) {
                    if (retType) { *retType = response.type; }
                    if (response.data.additional) {
                        nu_getTapiPPP()->ip_free(response.data.additional);
                    }
                    s_generalResponseQueue.RemoveAt(current);
                    break;
                }
            }
        }

        if (s_generalResponseQueue.GetCount()) {
            s_generalResponseEvent.Notify(1);
        }

        unlockGeneralResponseQueue();

        if (res != E_GEN_TIMEOUT) { break; }
        else {
            uint_t end = DzGetElapsedTicks();
            to -= (end - start);
        }
    }

    return res;
}

int getIndicatorMessage(VM_INDICATOR *ind)
{
    int cnt;
    lockIndicatorQueue4Zener();
    cnt = s_indicatorQueue.GetCount();
    unlockIndicatorQueue();
    while (cnt == 0 && g_VMStatus.monitorIndicator) {
        WaitResult wr;
        EventState stat;
        g_indicatorEvent.Wait(&wr, &stat);
        lockIndicatorQueue4Zener();
        cnt = s_indicatorQueue.GetCount();
        unlockIndicatorQueue();
    }
    lockIndicatorQueue4Zener();
    if (s_indicatorQueue.GetCount()) {
        *ind = s_indicatorQueue.RemoveHead();
        unlockIndicatorQueue();
        return 0;
    }
    unlockIndicatorQueue();
    return -1;
}


static void rAT_OK(T_ACI_AT_CMD cmdId)
{
#ifdef _VM_DEBUG
    char buf[80];
    sprintf(buf, "NU_LOG: -> rAT_OK cmdId.%d\n", cmdId);
    NU_LOG(buf);
#endif /* _VM_DEBUG */
    if (cmdId == AT_CMD_D) { return; }
    VM_RESPONSE_INTERNAL response;
    response.type = VM_GR_OK;
    response.cmdId = cmdId;
    addGeneralResponse(response);
}

static void rAT_NO_CARRIER( T_ACI_AT_CMD    cmdId,
                            SHORT cId )
{
#ifdef _VM_DEBUG
    char buf[64];
    sprintf(buf, "NU_LOG: -> rAT_NO_CARRIER cmdId.%d cId.%d\n", cmdId, cId);
    NU_LOG(buf);
#endif /* _VM_DEBUG */
}

static void rAT_CONNECT   ( T_ACI_AT_CMD    cmdId,
                            T_ACI_BS_SPEED  speed,
                            SHORT cId )
{
#ifdef _VM_DEBUG
    NU_LOG("NU_LOG: -> rAT_CONNECT cmdId.%d cId.%d\n", cmdId, cId);
#endif /* _VM_DEBUG */
}

static void rAT_BUSY      ( T_ACI_AT_CMD    cmdId,
                            SHORT cId )
{
#ifdef _VM_DEBUG
    NU_LOG("NU_LOG: -> rAT_BUSY cmdId.%d cId.%d\n", cmdId, cId);
#endif /* _VM_DEBUG */
}

static void rAT_NO_ANSWER ( T_ACI_AT_CMD    cmdId,
                            SHORT cId )
{
#ifdef _VM_DEBUG
    NU_LOG("NU_LOG: -> rAT_NO_ANSWER cmdId.%d cId.%d\n", cmdId, cId);
#endif /* _VM_DEBUG */
}

static void rAT_PlusCME   ( T_ACI_AT_CMD    cmdId,
                            T_ACI_CME_ERR   err )
{
    VM_RESPONSE_INTERNAL response;
    response.type = VM_GR_CME;
    response.cmdId = cmdId;
    response.data.value = err;
    addGeneralResponse(response);

    VM_INDICATOR ind;
    ind.type = VM_INDT_PlusCME;
    ind.data.PlusCME.cmdId = cmdId;
    ind.data.PlusCME.err = err;
    addIndicator(ind);

#ifdef _VM_DEBUG
    char buf[80] = {0};
    _sprintf(buf, "NU_LOG: rAT_PlusCME -> cmdId.%d,err.%d\n",
        cmdId, err);
    NU_LOG(buf);
#endif /* _VM_DEBUG */
}

static void rAT_PlusCMS   ( T_ACI_AT_CMD    cmdId,
                            T_ACI_CMS_ERR   err,
                            T_EXT_CMS_ERROR * conc_error )
{
    VM_RESPONSE_INTERNAL response;
    response.type = VM_GR_CMS;
    response.cmdId = cmdId;
    response.data.value = err;
    addGeneralResponse(response);

    VM_INDICATOR ind;
    ind.type = VM_INDT_PlusCMS;
    ind.data.PlusCMS.cmdId = cmdId;
    ind.data.PlusCMS.err = err;
    addIndicator(ind);

#ifdef _VM_DEBUG
    char buf[80] = {0};
    _sprintf(buf, "NU_LOG: rAT_PlusCMS -> cmdId.%d,err.%d\n",
        cmdId, err);
    NU_LOG(buf);
#endif /* _VM_DEBUG */
}

static void rAT_PlusCOPS  ( SHORT           lastIdx,
                            T_ACI_COPS_OPDESC * operLst )
{
#ifdef _VM_DEBUG
    char buf[256] = {0};
    _sprintf(buf, "NU_LOG: rAT_PlusCOPS -> lastid.%d\n", lastIdx);
    NU_LOG(buf);
#endif /* _VM_DEBUG */

    VM_RSP_tAT_PlusCOPS *pRsp = (VM_RSP_tAT_PlusCOPS *)
        nu_getTapiPPP()->ip_alloc(sizeof(VM_RSP_tAT_PlusCOPS));
    if (NULL == pRsp) {
        return;
    }
    memset(pRsp, 0, sizeof(VM_RSP_tAT_PlusCOPS));

    if (NULL == operLst) {
#ifdef _VM_DEBUG
        NU_LOG("NU_LOG: rAT_PlusCOPS -> NULL Pointer");
#endif /* _VM_DEBUG */
        goto _EXIT;
    }
    if (lastIdx < 0) goto _EXIT;
    if (lastIdx > (MMREG_MAX_PLMN_ID - 1)) lastIdx = MMREG_MAX_PLMN_ID - 1;

    for (int i = 0; i <= lastIdx; ++i) {
        if (operLst[i].status == COPS_STAT_NotPresent)
            break;

        pRsp->count++;
        pRsp->oper[i].status = operLst[i].status;
        strcpy(pRsp->oper[i].numOper, operLst[i].numOper);


#ifdef _VM_DEBUG
        _sprintf(buf, "NU_LOG: rAT_PlusCOPS -> numOper.%s %d ct.%d\n",
            pRsp->oper[i].numOper, pRsp->oper[i].status, pRsp->count);
        NU_LOG(buf);
#endif /* _VM_DEBUG */
    }

_EXIT:

    VM_RESPONSE_INTERNAL response;
    response.type = VM_GR_COPS;
    response.cmdId = AT_CMD_COPS;
    response.data.additional = pRsp;
    addGeneralResponse(response);
}

static void rAT_PlusCPIN  ( T_ACI_CPIN_RSLT rslt )
{
    VM_RSP_qAT_PlusCPIN *pRsp = (VM_RSP_qAT_PlusCPIN *)
        nu_getTapiPPP()->ip_alloc(sizeof(VM_RSP_qAT_PlusCPIN));
    if (NULL == pRsp) {
        return;
    }

    pRsp->pin = rslt;
    VM_RESPONSE_INTERNAL response;
    response.type = VM_GR_CPIN;
    response.cmdId = AT_CMD_CPIN;
    response.data.additional = pRsp;
    addGeneralResponse(response);
}

static void rAT_PlusCREG  ( T_ACI_CREG_STAT status ,
                            USHORT          lac,
                            USHORT          cid )
{
}

static void rAT_PercentCREG  ( T_ACI_CREG_STAT status ,
                            USHORT          lac,
                            USHORT          cid,
                            U8              gprs_ind,
                            U8              rt )
{
    VM_INDICATOR ind;
    ind.type = VM_INDT_PercentCREG;
    ind.data.PercentCREG.registerStatus = status;
    ind.data.PercentCREG.lac = lac;
    ind.data.PercentCREG.ci = cid;
    ind.data.PercentCREG.rt = rt;
    addIndicator(ind);

#ifdef _VM_DEBUG
    char buf[256] = {0};
    _sprintf(buf, "NU_LOG: rAT_PercentCREG STAT.%d,lac.%d,cid.%d,gprs_ind.%d,rt.%d\n",
        status, lac, cid, gprs_ind, rt);
    NU_LOG(buf);
#endif /* _VM_DEBUG */
}

static void rAT_PlusCRING ( T_ACI_CRING_MOD mode,
                            T_ACI_CRING_TYP type1,
                            T_ACI_CRING_TYP type2 )
{
#ifdef _VM_DEBUG
    char buf[100];
    _sprintf(buf, "NU_LOG: -> rAT_PlusCRING T_ACI_CRING_MOD.%d type1.%d type2.%d cmd.%d\n",
        mode, type1, type2, g_current_atcmd);
    NU_LOG(buf);
#endif /* _VM_DEBUG */
    if (g_current_atcmd != AT_CMD_NONE) {
        nu_ACI_GetCommand()->sAT_Abort(g_ACICmdSrc, g_current_atcmd);
    }

    VM_INDICATOR ind;
    ind.type = VM_INDT_PlusCRING;
    addIndicator(ind);
}

static void rAT_PlusCRING_OFF ( SHORT cId  )
{
#ifdef _VM_DEBUG
    NU_LOG("NU_LOG: -> rAT_PlusCRING_OFF cId.%d\n",cId);
#endif /* _VM_DEBUG */
}

#ifdef NO_ASCIIZ
static void rAT_PlusCLIP  ( T_ACI_CLIP_STAT stat,
                            CHAR            * number,
                            T_ACI_TOA       * type,
                            U8                validity,
                            CHAR            * subaddr,
                            T_ACI_TOS       * satype,
                            T_ACI_PB_TEXT   * alpha )
{

}

#else  /* ifdef NO_ASCIIZ */
static void rAT_PlusCLIP  ( T_ACI_CLIP_STAT stat,
                            CHAR            * number,
                            T_ACI_TOA       * type,
                            U8                validity,
                            CHAR            * subaddr,
                            T_ACI_TOS       * satype,
                            CHAR            * alpha )
{

}

#endif /* ifdef NO_ASCIIZ */

static  void rAT_PlusCDIP  ( CHAR       * number,
                             T_ACI_TOA  * type,
                             CHAR       * subaddr,
                             T_ACI_TOS  * satype )
{

}


static void rAT_PlusCLIR  ( T_ACI_CLIR_MOD  mode,
                            T_ACI_CLIR_STAT stat )
{
#ifdef _VM_DEBUG
    char buf[256] = {0};
    _sprintf(buf, "NU_LOG: -> rAT_PlusCLIR mode.%d stat.%d\n",
        mode, stat);
    NU_LOG(buf);
#endif /* _VM_DEBUG */
    VM_RSP_qAT_PlusCLIR *pRsp = (VM_RSP_qAT_PlusCLIR *)
        nu_getTapiPPP()->ip_alloc(sizeof(VM_RSP_qAT_PlusCLIR));
    if (NULL == pRsp) {
        return;
    }

    pRsp->mode = mode;
    pRsp->stat = stat;

    VM_RESPONSE_INTERNAL response;
    response.type = VM_GR_CLIR;
    response.cmdId = AT_CMD_CLIR;
    response.data.additional = pRsp;
    addGeneralResponse(response);
}

#ifdef NO_ASCIIZ
static void rAT_PlusCOLP  ( T_ACI_COLP_STAT stat,
                            CHAR          * number,
                            T_ACI_TOA     * type,
                            CHAR          * subaddr,
                            T_ACI_TOS     * satype,
                            T_ACI_PB_TEXT * alpha )
{

}

#else  /* ifdef NO_ASCIIZ */
static void rAT_PlusCOLP  ( T_ACI_COLP_STAT stat,
                            CHAR          * number,
                            T_ACI_TOA     * type,
                            CHAR          * subaddr,
                            T_ACI_TOS     * satype,
                            CHAR          * alpha )
{

}

#endif /* ifdef NO_ASCIIZ */
static void rAT_PlusDR    ( T_ACI_DR_TYP    type )
{

}

static void rAT_PlusCR    ( T_ACI_CR_SERV   service )
{

}

static void rAT_PlusCLCK  ( T_ACI_CLSSTAT * clsStat )
{
    if (NULL == clsStat) {
#ifdef _VM_DEBUG
        NU_LOG("NU_LOG: rAT_PlusCLCK -> NULL Pointer");
#endif /* _VM_DEBUG */
        return;
    }

    VM_RSP_qAT_PlusCLCK *pRsp = (VM_RSP_qAT_PlusCLCK *)
        nu_getTapiPPP()->ip_alloc(sizeof(VM_RSP_qAT_PlusCLCK));
    if (NULL == pRsp) {
        return;
    }

    pRsp->status = clsStat->status;
    pRsp->class_type = clsStat->class_type;

    VM_RESPONSE_INTERNAL response;
    response.type = VM_GR_CLCK;
    response.cmdId = AT_CMD_CLCK;
    response.data.additional = pRsp;
    addGeneralResponse(response);

#ifdef _VM_DEBUG
    char buf[256] = {0};
    _sprintf(buf, "NU_LOG: rAT_PlusCLCK -> class_type.%d, status.%d\n",
        clsStat->class_type, clsStat->status);
    NU_LOG(buf);
#endif /* _VM_DEBUG */
}

static void rAT_PlusCCFC  ( T_ACI_CCFC_SET* setting )
{
    if (NULL == setting) {
#ifdef _VM_DEBUG
        NU_LOG("NU_LOG: rAT_PlusCCFC -> NULL Pointer");
#endif /* _VM_DEBUG */
        return;
    }

    VM_RSP_qAT_PlusCCFC *pRsp = (VM_RSP_qAT_PlusCCFC *)
        nu_getTapiPPP()->ip_alloc(sizeof(VM_RSP_qAT_PlusCCFC));
    if (NULL == pRsp) {
        return;
    }

    pRsp->status = setting->clsstat.status;
    pRsp->class_type = setting->clsstat.class_type;
    memset(pRsp->number, 0, sizeof(pRsp->number));
    strcpy(pRsp->number, setting->number);
    pRsp->ton = setting->type.ton;
    pRsp->npi = setting->type.npi;
    memset(pRsp->subaddr, 0, sizeof(pRsp->subaddr));
    strcpy(pRsp->subaddr, setting->subaddr);
    pRsp->tos = setting->satype.tos;
    pRsp->oe = setting->satype.oe;
    pRsp->time = setting->time;

    VM_RESPONSE_INTERNAL response;
    response.type = VM_GR_CCFC;
    response.cmdId = AT_CMD_CCFC;
    response.data.additional = pRsp;
    addGeneralResponse(response);
}

#ifdef NO_ASCIIZ
static void rAT_PlusCCWA  ( T_ACI_CLSSTAT * clsStat,
                            CHAR          * number,
                            T_ACI_TOA     * type,
                            U8              validity,
                            T_ACI_CLASS     class_type,
                            T_ACI_PB_TEXT * alpha )
{
    if (clsStat) {
        VM_RSP_qAT_PlusCCWA *pRsp = (VM_RSP_qAT_PlusCCWA *)
            nu_getTapiPPP()->ip_alloc(sizeof(VM_RSP_qAT_PlusCCWA));
        if (NULL == pRsp) {
            return;
        }

        pRsp->status = clsStat->status;
        pRsp->class_type = clsStat->class_type;

        VM_RESPONSE_INTERNAL response;
        response.type = VM_GR_CCWA;
        response.cmdId = AT_CMD_CCWA;
        response.data.additional = pRsp;
        addGeneralResponse(response);
    }
    else {
        VM_INDICATOR ind;
        ind.type = VM_INDT_PlusCCWA;
        memset(&(ind.data.PlusCCWA), 0, sizeof(ind.data.PlusCCWA));
        if (number)
            strncpy(ind.data.PlusCCWA.number, number, VM_MAX_NUM_LEN);
        ind.data.PlusCCWA.toa = type?type->ton:TON_NotPresent;
        ind.data.PlusCCWA.npi = type?type->npi:NPI_NotPresent;
        addIndicator(ind);

    }
}

#else  /* ifdef NO_ASCIIZ */
static void rAT_PlusCCWA  ( T_ACI_CLSSTAT * clsStat,
                            CHAR          * number,
                            T_ACI_TOA     * type,
                            U8              validity,
                            T_ACI_CLASS     class_type,
                            CHAR          * alpha )
{
    if (clsStat) {
        VM_RSP_qAT_PlusCCWA *pRsp = (VM_RSP_qAT_PlusCCWA *)
            nu_getTapiPPP()->ip_alloc(sizeof(VM_RSP_qAT_PlusCCWA));
        if (NULL == pRsp) {
            return;
        }

        pRsp->status = clsStat->status;
        pRsp->class_type = clsStat->class_type;

        VM_RESPONSE_INTERNAL response;
        response.type = VM_GR_CCWA;
        response.cmdId = AT_CMD_CCWA;
        response.data.additional = pRsp;
        addGeneralResponse(response);

    }
    else {
        VM_INDICATOR ind;
        ind.type = VM_INDT_PlusCCWA;
        memset(&(ind.data.PlusCCWA), 0, sizeof(ind.data.PlusCCWA));
        if (number)
            strncpy(ind.data.PlusCCWA.number, number, VM_MAX_NUM_LEN);
        ind.data.PlusCCWA.toa = type?type->ton:TON_NotPresent;
        ind.data.PlusCCWA.npi = type?type->npi:NPI_NotPresent;

        addIndicator(ind);
    }
}

#endif /* ifdef NO_ASCIIZ */
static void rAT_PlusCSMS  ( T_ACI_CSMS_SERV service,
                            T_ACI_CSMS_SUPP mt,
                            T_ACI_CSMS_SUPP mo,
                            T_ACI_CSMS_SUPP bm )
{

}

static void rAT_PlusCPMS  ( T_ACI_SMS_STOR_OCC * mem1,
                            T_ACI_SMS_STOR_OCC * mem2,
                            T_ACI_SMS_STOR_OCC * mem3 )
{
    if (NULL == mem1 || NULL == mem2 || NULL == mem3) {
#ifdef _VM_DEBUG
        NU_LOG("NU_LOG: rAT_PlusCPMS -> NULL Pointer");
#endif /* _VM_DEBUG */
        return;
    }

    VM_RESPONSE_INTERNAL response;
    response.type = VM_GR_CPMS;
    response.cmdId = AT_CMD_CPMS;
    response.data.value = (mem1->used << 16) + mem1->total;
    addGeneralResponse(response);

#ifdef _VM_DEBUG
    char buf[256] = {0};
    _sprintf(buf, "NU_LOG: rAT_PlusCPMS->mem1.%d,%d,%d;mem2.%d,%d,%d;mem3.%d,%d,%d;\n",
        mem1->mem, mem1->used, mem1->total,
        mem2->mem, mem2->used, mem2->total,
        mem3->mem, mem3->used, mem3->total);
    NU_LOG(buf);
#endif /* _VM_DEBUG */
}

static void rAT_PlusCBMI  ( T_ACI_SMS_STOR  mem,
                            UBYTE           index )
{
}

static void rAT_PlusCMT   ( T_ACI_CMGL_SM*  sm )
{
/*
    VM_INDICATOR ind;
    ind.type = VM_INDT_PlusCMT;
    unsigned char *pdu = ind.data.PlusCMT.data;

    int i = 0;
    i += sms_EncodeSMSC(pdu + i, sm);
    pdu[i++] = sm->fo;
    i += sms_EncodeAddress(pdu + i, sm);
    pdu[i++] = sm->pid;
    pdu[i++] = sm->dcs;


    memcpy(pdu+i, sm->scts, 7);
    i += 7;
    memcpy(pdu+i, sm->udh.data, sm->udh.len);
    i += sm->udh.len;
    memcpy(pdu+i, sm->data.data, sm->data.len);
    i += sm->data.len;
    ind.data.PlusCMT.len = i;
    addIndicator(ind);

*/
}

static void rAT_PlusCMTPdu (T_MNSMS_MESSAGE_IND* pTpdu)
{
    if (NULL == pTpdu) {
#ifdef _VM_DEBUG
        NU_LOG("NU_LOG: rAT_PlusCMTPdu -> NULL Pointer");
#endif /* _VM_DEBUG */
        return;
    }

    VM_INDICATOR ind;
    ind.type = VM_INDT_PlusCMT;
    memcpy(ind.data.PlusCMT.data,
        &pTpdu->sms_sdu.buf[pTpdu->sms_sdu.o_buf >> 3],
        pTpdu->sms_sdu.l_buf >> 3);
    ind.data.PlusCMT.len = pTpdu->sms_sdu.l_buf >> 3;
    addIndicator(ind);

#ifdef _VM_DEBUG
    char buf[256] = {0};
    _sprintf(buf, "NU_LOG: rAT_PlusCMTPdu ->%d,%d,%d,%d\n",
        pTpdu->mem_type, pTpdu->rec_max, pTpdu->rec_num, pTpdu->status);
    NU_LOG(buf);
#endif /* _VM_DEBUG */
}

static void rAT_PlusCMTI  ( T_ACI_SMS_STOR  mem,
                            UBYTE           index,
                            T_ACI_CMGL_SM*  sm )
{
    VM_INDICATOR ind;
    ind.type = VM_INDT_PlusCMTI;
    ind.data.PlusCMTI.mem = mem;
    ind.data.PlusCMTI.index = index;
    addIndicator(ind);

#ifdef _VM_DEBUG
    char buf[256] = {0};
    _sprintf(buf, "NU_LOG: rAT_PlusCMTI -> mem.%d, index.%d\n",
        mem, index);
    NU_LOG(buf);
#endif /* _VM_DEBUG */
}

static void rAT_PlusCMGS  ( UBYTE           mr,
                            UBYTE           numSeg )
{
    VM_RESPONSE_INTERNAL response;
    response.type = VM_GR_CMGS;
    response.cmdId = AT_CMD_CMGS;
    response.data.value = mr;
    addGeneralResponse(response);

#ifdef _VM_DEBUG
    char buf[256] = {0};
    _sprintf(buf, "NU_LOG: -> rAT_PlusCMGS mr.%d numSeg.%d\n", mr, numSeg);
    NU_LOG(buf);
#endif /* _VM_DEBUG */
}

static void rAT_PercentCMGRS  ( T_ACI_CMGRS_MODE  mode,
                                UBYTE             tp_mr,
                                UBYTE             resend_count,
                                UBYTE             max_retrans )
{

}

static void rAT_PlusCMSS  ( UBYTE           mr,
                            UBYTE           numSeg )
{

}

static void rAT_PlusCMGW  ( UBYTE           index,
                            UBYTE           numSeg )
{
    struct VM_RSP_sAT_PlusCMGW *cmgw = (struct VM_RSP_sAT_PlusCMGW *)
        nu_getTapiPPP()->ip_alloc(
        sizeof(struct VM_RSP_sAT_PlusCMGW));
    if (cmgw == NULL) { return; }
    cmgw->index = index;
    cmgw->numSeg = numSeg;

    VM_RESPONSE_INTERNAL response;
    response.type = VM_GR_CMGW;
    response.cmdId = AT_CMD_CMGW;
    response.data.additional = cmgw;
    addGeneralResponse(response);

#ifdef _VM_DEBUG
    char buf[256] = {0};
    _sprintf(buf, "NU_LOG: -> rAT_PlusCMGW index.%d numSeg.%d\n", index, numSeg);
    NU_LOG(buf);
#endif /* _VM_DEBUG */

}

static void rAT_PlusCMGC  ( UBYTE           mr )
{

}

static void rAT_PlusCDS   ( T_ACI_CDS_SM*   st )
{

}


static void rAT_PlusCDSPdu(T_MNSMS_STATUS_IND * mnsms_status_ind )
{
    if (NULL == mnsms_status_ind) {
#ifdef _VM_DEBUG
        NU_LOG("NU_LOG: rAT_PlusCDSPdu -> NULL Pointer");
#endif /* _VM_DEBUG */
        return;
    }

    VM_INDICATOR ind;
    ind.type = VM_INDT_PlusCDS;
    memcpy(ind.data.PlusCDS.data,
        &mnsms_status_ind->sms_sdu.buf[mnsms_status_ind->sms_sdu.o_buf >> 3],
        mnsms_status_ind->sms_sdu.l_buf >> 3);
    ind.data.PlusCMT.len = mnsms_status_ind->sms_sdu.l_buf >> 3;
    addIndicator(ind);
}


static void rAT_PlusCBM   ( SHORT           sn,
                            SHORT           mid,
                            SHORT           dcs,
                            UBYTE           page,
                            UBYTE           pages,
                            T_ACI_CBM_DATA* data )
{

}

static void rAT_PlusCBMPdu(T_ACI_CBM_DATA* data)
{
    if (NULL == data) {
#ifdef _VM_DEBUG
        NU_LOG("NU_LOG: rAT_PlusCBMPdu -> NULL Pointer");
#endif /* _VM_DEBUG */
        return;
    }

    VM_INDICATOR ind;
    ind.type = VM_INDT_PlusCBM;
    memcpy(ind.data.PlusCBM.data, data->data, data->len),
    ind.data.PlusCBM.len = data->len;
    addIndicator(ind);
}

static void rAT_PlusILRR  ( T_ACI_BS_SPEED  speed,
                            T_ACI_BS_FRM    format,
                            T_ACI_BS_PAR    parity )
{

}

static void rAT_PlusCMGR  ( T_ACI_CMGL_SM*  sm,
                            T_ACI_CMGR_CBM* cbm )
{
}

static void rAT_PecentCMGRPdu(T_MNSMS_READ_CNF *mnsms_read_cnf)
{
    if (NULL == mnsms_read_cnf) {
#ifdef _VM_DEBUG
        NU_LOG("NU_LOG: rAT_PecentCMGRPdu -> NULL Pointer");
#endif /* _VM_DEBUG */
        return;
    }

#ifdef _VM_DEBUG
    char dbgBuf[80];
    NU_LOG("NU_LOG: -> rAT_PecentCMGRPdu\n");
    for (int i = 0; i < (mnsms_read_cnf->sms_sdu.l_buf >> 3); i++) {
        sprintf(dbgBuf, "%02x.", mnsms_read_cnf->sms_sdu.buf[i]);
        NU_LOG(dbgBuf);
    }
    NU_LOG("\n");
#endif /* _VM_DEBUG */
    struct VM_RSP_sAT_PlusCMGR *cmgr = (struct VM_RSP_sAT_PlusCMGR *)
        nu_getTapiPPP()->ip_alloc(
        sizeof(struct VM_RSP_sAT_PlusCMGR));
    if (cmgr == NULL) { return; }
    cmgr->location = 0;
    cmgr->index = mnsms_read_cnf->rec_num + 1;
    cmgr->status = mnsms_read_cnf->status;
    memcpy(cmgr->pdu,
        &mnsms_read_cnf->sms_sdu.buf[mnsms_read_cnf->sms_sdu.o_buf >> 3],
        mnsms_read_cnf->sms_sdu.l_buf >> 3);
    cmgr->len = (mnsms_read_cnf->sms_sdu.l_buf >> 3);

    VM_RESPONSE_INTERNAL response;
    response.type = VM_GR_CMGR;
    response.cmdId = AT_CMD_CMGR;
    response.data.additional = cmgr;
    addGeneralResponse(response);
}

static void rAT_PlusCMGD  ( void )
{

}

static void rAT_PlusCMGL  ( T_ACI_CMGL_SM  *smLst )
{
#ifdef _VM_DEBUG
    NU_LOG("NU_LOG: -> rAT_PlusCMGL: %d,%d,%s\n",
        smLst->index, smLst->stat, smLst->adress);
#endif /* _VM_DEBUG */
}

static void rAT_PecentCMGLPdu(T_MNSMS_READ_CNF *mnsms_read_cnf)
{
#ifdef _VM_DEBUG
    NU_LOG("NU_LOG: -> rAT_PecentCMGLPdu\n");
    for (int i = 0; i < (mnsms_read_cnf->sms_sdu.l_buf >> 3); i++) {
        NU_LOG("%02x.", mnsms_read_cnf->sms_sdu.buf[i]);
    }
    NU_LOG("\nNU_LOG: -> rAT_PecentCMGLPdu -> end\n");
#endif /* _VM_DEBUG */
}

static void rAT_PlusCUSD  ( T_ACI_CUSD_MOD   m,
                            T_ACI_USSD_DATA *ussd,
                            SHORT            dcs )
{
}

static void rAT_PlusCCCM  ( LONG           *ccm )
{

}

static void rAT_PlusCSSI  ( T_ACI_CSSI_CODE code,
                            SHORT           index )
{

}

static void rAT_PlusCSSU  ( T_ACI_CSSU_CODE code,
                            SHORT           index,
                            CHAR           *number,
                            T_ACI_TOA      *type,
                            CHAR           *subaddr,
                            T_ACI_TOS      *satype )
{

}

static void rAT_PercentCCCN ( T_ACI_FAC_DIR tDirection,
                              SHORT         cId,
                              T_NAS_fac_inf     *acFie )
{

}

static void rAT_PercentCSSN ( T_ACI_FAC_DIR        tDirection,
                              T_ACI_FAC_TRANS_TYPE tType,
                              T_NAS_fac_inf            *acFie )
{

}

static void rAT_PlusCPOL  ( SHORT              startIdx,
                            SHORT              lastIdx,
                            T_ACI_CPOL_OPDESC *operLst,
                            SHORT              usdNtry )
{
#ifdef _VM_DEBUG
    char buf[256] = {0};
    sprintf(buf, "NU_LOG: -> rAT_PlusCPOL start.%d,last.%d,%p,usd.%d\n",
        startIdx, lastIdx, operLst,usdNtry);
    NU_LOG(buf);
#endif /* _VM_DEBUG */

    if (NULL == operLst) {
#ifdef _VM_DEBUG
        NU_LOG("NU_LOG: rAT_PlusCPOL -> NULL Pointer operLst");
#endif /* _VM_DEBUG */
        return;
    }

    VM_RSP_qAT_PlusCPOL *pRsp = (VM_RSP_qAT_PlusCPOL *)
        nu_getTapiPPP()->ip_alloc(sizeof(VM_RSP_qAT_PlusCPOL));
    if (NULL == pRsp) {
        return;
    }
    memset(pRsp, 0, sizeof(VM_RSP_qAT_PlusCPOL));

    pRsp->count = lastIdx;
    for (int i = 0; i < lastIdx; ++i) {
        pRsp->oper[i].index = operLst[i].index;
        pRsp->oper[i].format = operLst[i].format;
        strcpy(pRsp->oper[i].oper, operLst[i].oper);

#ifdef _VM_DEBUG
        _sprintf(buf, "NU_LOG: rAT_PlusCPOL -> oper.%s,index.%d\n",
            pRsp->oper[i].oper, pRsp->oper[i].index);
        NU_LOG(buf);
#endif /* _VM_DEBUG */
    }

    VM_RESPONSE_INTERNAL response;
    response.type = VM_GR_CPOL;
    response.cmdId = AT_CMD_CPOL;
    response.data.additional = pRsp;
    addGeneralResponse(response);

}


static void rAT_PlusCLAN  ( T_ACI_LAN_SUP  *CLang )
{

}

static void rAT_PlusCLAE  ( T_ACI_LAN_SUP  *CLang )
{

}


#ifdef TI_UMTS
static void rAT_PercentCSQ  (UBYTE rssi, UBYTE ber, UBYTE actrssilevel, UBYTE rscp, UBYTE actrscplevel )
{
}

#else
static void rAT_PercentCSQ  (UBYTE rssi, UBYTE ber, UBYTE actlevel )
{
    static UBYTE prelevel = 0;
    if( prelevel != actlevel )
    {
        VM_INDICATOR ind;
        ind.type = VM_INDT_PercentCSQ;
        ind.data.PercentCSQ.rssi = rssi;
        ind.data.PercentCSQ.ber = ber;
        ind.data.PercentCSQ.actlevel = actlevel;
        addIndicator(ind);
        prelevel = actlevel;
    }
}

#endif

static void rAT_PlusCIMI  ( CHAR           *imsi )
{

}

static void rAT_PlusCNUM  ( T_ACI_CNUM_MSISDN *msisdn,
                            UBYTE              num )
{

}

static void rAT_PlusCRSM  ( SHORT           sw1,
                            SHORT           sw2,
                            SHORT           rspLen,
                            UBYTE          *rsp    )
{
#ifdef _VM_DEBUG
        char buf[100];
        sprintf(buf, "NU_LOG: rAT_PlusCRSM -> sw1.0x%x sw2.0x%x len.%d rsp.%p\n",
            sw1, sw2, rspLen, rsp);
        NU_LOG(buf);
#endif /* _VM_DEBUG */

    struct VM_RSP_sAT_PlusCRSM *crsm = (struct VM_RSP_sAT_PlusCRSM *)
        nu_getTapiPPP()->ip_alloc(
        sizeof(struct VM_RSP_sAT_PlusCRSM));
    if (crsm == NULL) { return; }
    crsm->sw1 = sw1;
    crsm->sw2 = sw2;
    crsm->rspLen = rspLen;
    if (rsp)
        memcpy(crsm->rsp, rsp, rspLen);
    VM_RESPONSE_INTERNAL response;
    response.type = VM_GR_CRSM;
    response.cmdId = AT_CMD_CRSM;
    response.data.additional = crsm;
    addGeneralResponse(response);

}

static void rAT_PlusCSIM  ( SHORT           rspLen,
                            UBYTE          *rsp    )
{
#ifdef _VM_DEBUG
    char buf[100];
    sprintf(buf, "NU_LOG: rAT_PlusCSIM -> len.%d rsp.%p\n", rspLen, rsp);
    NU_LOG(buf);
#endif /* _VM_DEBUG */

    struct VM_RSP_sAT_PlusCSIM *csim = (struct VM_RSP_sAT_PlusCSIM *)
        nu_getTapiPPP()->ip_alloc(
        sizeof(struct VM_RSP_sAT_PlusCSIM));
    if (csim == NULL) { return; }
    csim->rspLen = rspLen;
    if (rsp)
        memcpy(csim->rsp, rsp, rspLen);
    VM_RESPONSE_INTERNAL response;
    response.type = VM_GR_CSIM;
    response.cmdId = AT_CMD_CSIM;
    response.data.additional = csim;
    addGeneralResponse(response);
}

static void rAT_PlusCGCMOD( void )
{

}

static void rAT_PlusCCWV  ( T_ACI_CCWV_CHRG charging )
{

}

static void rAT_PercentSQ ( BYTE            segm )
{

}

static void rAT_PercentBC ( BYTE            segm )
{

}

static void rAT_PercentDRV( T_ACI_DRV_DEV   device,
                            T_ACI_DRV_FCT   function,
                            UBYTE           val1,
                            UBYTE           val2 )
{

}

static void rAT_PercentSIMREM( T_ACI_SIMREM_TYPE srType )
{
#ifdef _VM_DEBUG
    char buf[100];
    _sprintf(buf, "rAT_PercentSIMREM -> srType.%d\n", srType);
    NU_LOG(buf);
#endif /* _VM_DEBUG */
    VM_INDICATOR ind;
    ind.type = VM_INDT_PercentSIMREM;
    ind.data.PercentSIMREM.srType = srType;
    addIndicator(ind);
}

static void rAT_PercentSIMINS( T_ACI_CME_ERR     err    )
{
#ifdef _VM_DEBUG
        char buf[100];
        _sprintf(buf, "rAT_PercentSIMINS -> err.%d\n", err);
        NU_LOG(buf);
#endif /* _VM_DEBUG */
}

static void rAT_PercentCOLR  ( T_ACI_COLR_STAT stat )
{

}

static void rAT_PercentCLOG  ( T_ACI_CLOG     *cmd )
{
#ifdef _VM_DEBUG
    NU_LOG("NU_LOG: -> rAT_PercentCLOG atCmd.%d cmdType.%d retCode.%d sId.%d\n",
        cmd->atCmd, cmd->cmdType, cmd->retCode, cmd->sId);
#endif /* _VM_DEBUG */
}

static void rAT_PercentKSIR  ( T_ACI_KSIR     *ksStat )
{
#ifdef _VM_DEBUG
        char buf[256] = {0};
        _sprintf(buf, "VM: rAT_PercentKSIR -> srcId.%d ksdCmd.%d\n",
            ksStat->srcId, ksStat->ksdCmd);
        NU_LOG(buf);
#endif /* _VM_DEBUG */

    if (ksStat->ksdCmd == KSD_CMD_USSD) {
#ifdef _VM_DEBUG
        _sprintf(buf, "VM: rAT_PercentKSIR -> CUSD dcs.0x%x len.%d mode.%d\n",
            ksStat->ir.rKSUS.dcs, ksStat->ir.rKSUS.len, ksStat->ir.rKSUS.mode);
        NU_LOG(buf);
#endif /* _VM_DEBUG */

        VM_INDICATOR ind;
        ind.type = VM_INDT_PlusCUSD;
        ind.data.PlusCUSD.m = ksStat->ir.rKSUS.mode;
        ind.data.PlusCUSD.len = ksStat->ir.rKSUS.len;
        ind.data.PlusCUSD.dcs = ksStat->ir.rKSUS.dcs;
        if (ksStat->ir.rKSUS.len != 0) {
            memcpy(ind.data.PlusCUSD.data, ksStat->ir.rKSUS.ussd, ksStat->ir.rKSUS.len);
        }
        else {
            memset(ind.data.PlusCUSD.data, 0x00, sizeof(ind.data.PlusCUSD.data));
        }

        addIndicator(ind);
    }
}

static void rAT_PercentCPI   ( SHORT           cId,
                               T_ACI_CPI_MSG   msgType,
                               T_ACI_CPI_IBT   ibt,
                               T_ACI_CPI_TCH   tch,
                               USHORT          cause )
{
    // Call Progress Information
    VM_INDICATOR ind;
    ind.type = VM_INDT_PercentCPI;
    ind.data.PercentCPI.cId= cId;
    ind.data.PercentCPI.msgType = msgType;
    ind.data.PercentCPI.ibt = ibt;
    ind.data.PercentCPI.tch = tch;
    ind.data.PercentCPI.cause = cause;
    addIndicator(ind);

#ifdef _VM_DEBUG
    char buf[256] = {0};
    _sprintf(buf, "VM: rAT_PercentCPI->cId.%d,msgType.%d,ibt.%d,tch.%d,cause.%d\n",
        cId, msgType, ibt, tch, cause);
    NU_LOG(buf);
#endif /* _VM_DEBUG */
}

static void rAT_PercentCSTAT (T_ACI_STATE_MSG msgType )
{
#ifdef _VM_DEBUG
    char buf[256] = {0};
    _sprintf(buf, "rAT_PercentCSTAT id.%d state.%d\n",
        msgType.entityId, msgType.entityState);
    NU_LOG(buf);
#endif /* _VM_DEBUG */
}

static void rAT_PercentCPRSM (T_ACI_CPRSM_MOD mode )
{
}

static void rAT_PercentALS  ( T_ACI_ALS_MOD ALSmode )
{
#ifdef _VM_DEBUG
    char buf[256] = {0};
    _sprintf(buf, "rAT_PercentALS ALSmode.%d\n", ALSmode);
    NU_LOG(buf);
#endif /* _VM_DEBUG */
}


static void rAT_PercentCTYI  ( T_ACI_CTTY_NEG  neg,
                               T_ACI_CTTY_TRX  trx )
{
}

static void rAT_PercentCTV   ( void )
{
    // Call Timer
    /*
    The function rAT_PercentCTV is called to inform the application about
    a call timer timeout, which occurs every second. The current and accumulated
    call timer was increased. */
}

#if defined SIM_TOOLKIT || defined (TI_PS_FF_TRANSPARENT_SAT)
static void rAT_PercentSATI  ( SHORT           len,
                               UBYTE          *satCmd )
{
    if (NULL == satCmd) {
#ifdef _VM_DEBUG
        NU_LOG("NU_LOG: rAT_PercentSATI -> NULL Pointer");
#endif /* _VM_DEBUG */
        return;
    }

    VM_INDICATOR ind;
    ind.type = VM_INDT_PercentSATI;
    memcpy(ind.data.PercentSATI.satCmd, satCmd, len);
    ind.data.PercentSATI.length = len;
    addIndicator(ind);

}

static void rAT_PercentSATE  ( SHORT           len,
                               UBYTE          *satCmd )
{
    if (NULL == satCmd) {
#ifdef _VM_DEBUG
        NU_LOG("NU_LOG: rAT_PercentSATE -> NULL Pointer");
#endif /* _VM_DEBUG */
        return;
    }

    VM_INDICATOR ind;
    ind.type = VM_INDT_PercentSATE;
    memcpy(ind.data.PercentSATE.satRsp, satCmd, len);
    ind.data.PercentSATE.length = len;
    addIndicator(ind);
}

#endif /* SIM_TOOLKIT or TI_PS_FF_TRANSPARENT_SAT */
#ifdef SIM_TOOLKIT
static void rAT_PercentSATN  ( SHORT           len,
                               UBYTE          *satCmd )
{
    if (NULL == satCmd) {
#ifdef _VM_DEBUG
        NU_LOG("NU_LOG: rAT_PercentSATN -> NULL Pointer");
#endif /* _VM_DEBUG */
        return;
    }

    VM_INDICATOR ind;
    ind.type = VM_INDT_PercentSATN;
    memcpy(ind.data.PercentSATN.satNtfy, satCmd, len);
    ind.data.PercentSATN.length = len;
    addIndicator(ind);
}

#ifdef TI_PS_FF_SATE
static void rAT_PercentSATA  ( SHORT           cId,
                               LONG            rdlTimeout_ms,
                               T_ACI_SATA_ADD *addParm )
{
#ifdef _VM_DEBUG
    NU_LOG("NU_LOG: -> rAT_PercentSATA %s, %d\n",
        __FILE__, __LINE__);
#endif /* _VM_DEBUG */
}

static void rCI_PercentSATT  ( T_ACI_CMD_SRC  srcId,
                                   T_ACI_SATT_CS  cause )
{
#ifdef _VM_DEBUG
    NU_LOG("NU_LOG: -> rCI_PercentSATT %s, %d\n",
        __FILE__, __LINE__);
#endif /* _VM_DEBUG */
}

#else
static void rAT_PercentSATA  ( SHORT           cId,
                               LONG            rdlTimeout_ms )
{
    VM_INDICATOR ind;
    ind.type = VM_INDT_PercentSATA;
    ind.data.PercentSATA.rdl = rdlTimeout_ms;
    addIndicator(ind);

}

#endif /* TI_PS_FF_SATE */

static void rAT_PercentSATT  ( T_ACI_CMD_SRC  srcId,
                               T_ACI_SATT_CS  cause )
{
#ifdef _VM_DEBUG
    NU_LOG("NU_LOG: -> rCI_PercentSATT %s, %d\n",
        __FILE__, __LINE__);
#endif /* _VM_DEBUG */
}

static void rAT_SatFUN ( int ref, T_SIM_FILE_UPDATE_IND* mmi_insert_ind )
{
}

static void rAT_SatFRN ( int ref, T_SIM_FILE_UPDATE_IND* mmi_insert_ind )
{
}


#endif  /* SIM_TOOLKIT */
static void rAT_PercentCCBS  ( T_ACI_CCBS_IND  indct,
                               T_ACI_CCBS_STAT status,
                               T_ACI_CCBS_SET *setting )
{
}

static void rAT_PercentCNAP  ( T_callingName *NameId, T_ACI_CNAP_STATUS status )
{
}

static void rAT_PlusCTZV     ( S8 time_zone )
{
}

INLINE uint32_t RTCTimeToSeconds(
	const T_ACI_RTC_DATE *pDate,
	const T_ACI_RTC_TIME *pTime)
{
    assert(pDate && pTime);

    int nMonth  = pDate->month;
    int nYear   = pDate->year;
    int nDate   = pDate->day;
    nMonth -= 2;            // 1..12 -> 11,12,1..10
    if (0 >= nMonth) {
        nMonth  += 12;      // Puts Feb last since it has leap day
        nYear   -= 1;
    }

    uint32_t uSeconds = (uint_t)(nYear / 4 - nYear / 100 + nYear / 400
            + 367 * nMonth / 12 + nDate) + nYear * 365 - 719499;

    uSeconds = uSeconds * 24 + pTime->hour;    // now have hours
    uSeconds = uSeconds * 60 + pTime->minute;  // now have minutes
    uSeconds = uSeconds * 60 + pTime->second;  // finally seconds

    return uSeconds;
}

static void rAT_PercentCTZV  ( T_MMREG_INFO_IND *mmr_info_ind, S8 timezone )
{
#ifdef _VM_DEBUG
    char buf[128];
    sprintf(buf, "NU_LOG: -> SyncNetTime rAT_PercentCTZV %d/%02d/%02d,%02d:%02d:%02d%+02d,%+1d\n",
                       mmr_info_ind->universal_time.year,
                       mmr_info_ind->universal_time.month,
                       mmr_info_ind->universal_time.day,
                       mmr_info_ind->universal_time.hour,
                       mmr_info_ind->universal_time.minute,
                       mmr_info_ind->universal_time.second,
                       timezone,
                       mmr_info_ind->net_daylight_save_time);
    nu_puts(buf);
#endif /* _VM_DEBUG */
    if (g_SyncTimeEnabled) {
        T_ACI_RTC_DATE date;
        T_ACI_RTC_TIME time;

        date.day = mmr_info_ind->universal_time.day;
        date.month = mmr_info_ind->universal_time.month;
        date.year = mmr_info_ind->universal_time.year + 2000;

        time.hour = mmr_info_ind->universal_time.hour;
        time.minute = mmr_info_ind->universal_time.minute;
        time.second = mmr_info_ind->universal_time.second;
        time.format = TIME_FORMAT_24HOUR;
        time.PM_flag = 0;

		SystemTime systemTime, netTime;
		
		DzGetSystemTime(&systemTime);
		
		netTime.seconds = RTCTimeToSeconds(&date, &time);
		
#ifdef _VM_DEBUG		
	    sprintf(buf, "NU_LOG: -> SyncNetTime Before Syc systemTime.%d netTime.%d\n",
	                       systemTime.seconds, netTime.seconds);
	    nu_puts(buf);
#endif /* _VM_DEBUG */	
		int delt = systemTime.seconds - netTime.seconds;

		if (delt < -2 || delt > 2) {
	        g_SyncTimeElapsed = _GetElapsed();
	        T_ACI_RETURN ret = nu_ACI_GetCommand()->sAT_PlusCCLK(
	                                                g_ACICmdSrc, &date, &time);

	        VM_INDICATOR ind;	
	        ind.type = VM_INDT_PlusCCLK;		
	        ind.data.PlusCCLK.day = date.day;
	        ind.data.PlusCCLK.month = date.month;
	        ind.data.PlusCCLK.year = date.year;
	        ind.data.PlusCCLK.hour = time.hour;
	        ind.data.PlusCCLK.minute = time.minute;
	        ind.data.PlusCCLK.second = time.second;
			
			if (ret == AT_CMPL) {
				ind.data.PlusCCLK.flag = 1;
			}
			else {
			    ind.data.PlusCCLK.flag = 0;
				g_SyncTimeElapsed = 0;				
			}

	        addIndicator(ind);

#ifdef _VM_DEBUG
			DzGetSystemTime(&systemTime);
		    sprintf(buf, "NU_LOG: -> SyncNetTime After Syc systemTime.%d\n",
		                       systemTime.seconds);
		    nu_puts(buf);
#endif /* _VM_DEBUG */	
		}
    }
}

static void rAT_PercentCNIV  ( T_MMREG_INFO_IND *mmr_info_ind )
{
}


static void rAT_SignalSMS    ( UBYTE state )
{
    VM_INDICATOR ind;
    ind.type = VM_INDT_SignalSMS;
    ind.data.SignalSMS.status = state;
    addIndicator(ind);


#ifdef _VM_DEBUG
    char buf[256] = {0};
    _sprintf(buf, "rAT_SignalSMS state.%d\n", state);
    NU_LOG(buf);
#endif /* _VM_DEBUG */
}


static void rAT_phb_status   ( T_ACI_PB_STAT status )
{
    VM_INDICATOR ind;
    ind.type = VM_INDT_PhbStatus;
    ind.data.PhbStatus.status = status;
    addIndicator(ind);

#ifdef _VM_DEBUG
    char buf[256] = {0};
    _sprintf(buf, "rAT_phb_status status.%d\n", status);
    NU_LOG(buf);
#endif /* _VM_DEBUG */

    g_VMStatus.pbStatus = status;
}

static void rAT_sms_ready    ( void )
{
    VM_INDICATOR ind;
    ind.type = VM_INDT_SignalSMS;
    ind.data.SignalSMS.status = 0xff;
    addIndicator(ind);

#ifdef _VM_DEBUG
    char buf[256] = {0};
    _sprintf(buf, "rAT_sms_ready\n");
    NU_LOG(buf);
#endif /* _VM_DEBUG */
}


static void rAT_PlusCIEV( T_ACI_MM_CIND_VAL_TYPE sCindValues, T_ACI_MM_CMER_VAL_TYPE sCmerSettings )
{
    // CALL_ELASTOS_VMODEM_2(rAT_PlusCIEV, sCindValues, sCmerSettings);
}

static void rAT_PlusCKEV( T_ACI_CKEV_VALUES sCkevValues, T_ACI_CMER_MODE_TYPE mode )
{
    // CALL_ELASTOS_VMODEM_2(rAT_PlusCKEV, sCkevValues, mode);
}

static void rAT_PercentCPKY(CHAR *keys, SHORT time, SHORT pause )
{
    // CALL_ELASTOS_VMODEM_3(rAT_PercentCPKY, keys, time, pause);
}


#ifdef TI_PS_FF_EM
static void rAT_PercentEINFO (U16 offset, U16 length, T_ENG_INFO_REQ *eng_info_req )
{
    // CALL_ELASTOS_VMODEM_3(rAT_PercentEINFO, offset, length, eng_info_req);
}

static void rAT_PercentESINFO (U16 offset, U16 length, T_ENG_INFO_STATIC_REQ *eng_info_static_req )
{
    // CALL_ELASTOS_VMODEM_3(rAT_PercentESINFO, offset, length, eng_info_static_req);
}

#endif /* TI_PS_FF_EM */

static void rAT_PercentRDL(T_ACI_CC_REDIAL_STATE state )
{
    // CALL_ELASTOS_VMODEM_1(rAT_PercentRDL, state);
}

static void rAT_PercentRDLB(T_ACI_CC_RDL_BLACKL_STATE state )
{
    // CALL_ELASTOS_VMODEM_1(rAT_PercentRDLB, state);
}


#ifdef FF_GPS
static void rAT_PercentGPSN ( U8 ntfyType, U8 locType, U8 *clientID, U8 * clientName )
{
    // CALL_ELASTOS_VMODEM_4(rAT_PercentGPSN, ntfyType, locType, clientID, clientName);
}

static void rAT_PercentGPSR( U8 cause, U8 format, U8 *data )
{
    // CALL_ELASTOS_VMODEM_3(rAT_PercentGPSR, cause, format, data);
}

#endif

static void rAT_PercentCPRI  ( UBYTE gsm_ciph,
                               UBYTE gprs_ciph )
{
    // Ciphering Indication
}


#if defined(TI_UMTS) && defined(TI_PS_3GPP_R5)
static void rAT_PercentMMCI ( T_ACI_MMCI_STAT state )
{
    // CALL_ELASTOS_VMODEM_1(rAT_PercentMMCI, state);
}

#endif /* TI_UMTS && TI_PS_3GPP_R5 */

static void rAT_PercentSIMEF (T_SIM_FILE_UPDATE_IND *updateInd )
{
    // CALL_ELASTOS_VMODEM_1(rAT_PercentSIMEF, updateInd);
}


static void rAT_PlusCLVL(U8 volume )
{
    // CALL_ELASTOS_VMODEM_1(rAT_PlusCLVL, volume);
}

static void rAT_PlusCMUT(U8 volume )
{
    // CALL_ELASTOS_VMODEM_1(rAT_PlusCMUT, volume);
}

static void rAT_PlusCRSL(U8 volume )
{
    // CALL_ELASTOS_VMODEM_1(rAT_PlusCRSL, volume);
}


static void rAT_PercentCMGR  ( T_ACI_CMGL_SM*  sm,
                               T_ACI_CMGR_CBM* cbm )
{
    // CALL_ELASTOS_VMODEM_2(rAT_PercentCMGR, sm, cbm);
}


static void rAT_PercentCMGL  ( T_ACI_CMGL_SM  *smLst )
{
    // CALL_ELASTOS_VMODEM_1(rAT_PercentCMGL, smLst);
}

static void rBAT_PlusCMGL(
  T_MNSMS_READ_CNF *mnsms_read_cnf )
{
    // CALL_ELASTOS_VMODEM_1(rBAT_PlusCMGL, mnsms_read_cnf);
}


static void rBAT_PercentCMGR(
  T_MNSMS_READ_CNF *mnsms_read_cnf,
  T_ACI_CMGR_CBM *cbm )
{
    // CALL_ELASTOS_VMODEM_2(rBAT_PercentCMGR, mnsms_read_cnf, cbm);
}

#ifdef TI_PS_FF_EM
static void rBAT_PercentEINFO (U16 offset, U16 length, T_ENG_INFO_REQ *eng_info_req )
{
    // CALL_ELASTOS_VMODEM_3(rBAT_PercentEINFO, offset, length, eng_info_req);
}


static void rBAT_PercentESINFO (U16 offset, U16 length, T_ENG_INFO_STATIC_REQ *eng_info_static_req )
{
    // CALL_ELASTOS_VMODEM_3(rBAT_PercentESINFO, offset, length, eng_info_static_req);
}
#endif /* TI_PS_FF_EM */

static void rAT_PlusPACSP (U8 srcId, U8 cspStat )
{
    // CALL_ELASTOS_VMODEM_2(rAT_PlusPACSP, srcId, cspStat);
}

   /* OMAPS00082147 */

#ifdef TI_PS_3GPP_R5
static void rAT_PercentMBI   ( T_BAT_cmd_response *pCmdResp )
{
    // CALL_ELASTOS_VMODEM_1(rAT_PercentMBI, pCmdResp);
}

static void rAT_PercentMBDN  ( T_BAT_cmd_response *pCmdResp )
{
    // CALL_ELASTOS_VMODEM_1(rAT_PercentMBDN, pCmdResp);
}

static void rAT_PercentMWIS  ( T_BAT_cmd_response *pCmdResp )
{
    // CALL_ELASTOS_VMODEM_1(rAT_PercentMWIS, pCmdResp);
}

static void rAT_PercentCFIS  ( T_BAT_cmd_response *pCmdResp )
{
    // CALL_ELASTOS_VMODEM_1(rAT_PercentCFIS, pCmdResp);
}

static void rAT_PercentMWI   ( T_BAT_cmd_response *pCmdResp )
{
    // CALL_ELASTOS_VMODEM_1(rAT_PercentMWI, pCmdResp);
}

#endif

static void rAT_PercentCAUSE (T_CAUSE_ctrl_value ctrl_value, T_CAUSE_value cause_value )
{
    // CALL_ELASTOS_VMODEM_2(rAT_PercentCAUSE, ctrl_value, cause_value);
}

static void rAT_PercentRLOG  ( T_ACI_RLOG *rslt )
{

}
static  void rAT_PlusCGACT            ( SHORT link_id )
{
}
static  void rAT_PlusCGDATA           ( SHORT link_id )
{
}
static  void rAT_PlusCGANS            ( SHORT link_id )
{
}
static  void rAT_PlusCGEREP           ( T_CGEREP_EVENT event, T_CGEREP_EVENT_REP_PARAM *param )
{
    if (NULL == param) {
#ifdef _VM_DEBUG
        NU_LOG("NU_LOG: rAT_PlusCGEREP -> NULL Pointer");
#endif /* _VM_DEBUG */
        return;
    }

    if (event == CGEREP_EVENT_NW_REACT ||
        event == CGEREP_EVENT_NW_ACT ||
        event == CGEREP_EVENT_ME_ACT) {
        if (param) {
            VM_INDICATOR ind;
            ind.type = VM_INDT_PlusCGEREP;
            ind.data.PlusCGEREP.event = 1;
            ind.data.PlusCGEREP.cid = param->act.cid;
            addIndicator(ind);

        }
    }
    else if (/* event == CGEREP_EVENT_REJECT || */
        event == CGEREP_EVENT_NW_DEACT ||
        event == CGEREP_EVENT_ME_DEACT ||
        event == CGEREP_EVENT_NW_DETACH ||
        event == CGEREP_EVENT_ME_DETACH) {
        if (param) {
            VM_INDICATOR ind;
            ind.type = VM_INDT_PlusCGEREP;
            ind.data.PlusCGEREP.event = 0;
            ind.data.PlusCGEREP.cid = param->act.cid;
            addIndicator(ind);

        }
    }
}

static  void rAT_PlusCGREG            ( T_CGREG_STAT stat, USHORT lac, USHORT ci )
{
    VM_INDICATOR ind;
    ind.type = VM_INDT_PlusCGREG;
    ind.data.PlusCGREG.registerStatus = stat;
    ind.data.PlusCGREG.lac = lac;
    ind.data.PlusCGREG.ci = ci;
    addIndicator(ind);
}
static  void rAT_changedQOS           ( U8 cid, T_PS_qos *qos )
{
}
static  void rAT_PercentSNCNT         ( UBYTE c_id,
                                       ULONG octets_uplink,
                                       ULONG octets_downlink,
                                       ULONG packets_uplink,
                                       ULONG packets_downlink )
{
}
static  void rAT_PercentCGREG         ( T_P_CGREG_STAT stat, USHORT lac, USHORT ci, BOOL bActiveContext )
{
#ifdef _VM_DEBUG
    char buf[100];
    sprintf(buf, "NU_LOG: -> rAT_PercentCGREG stat.%d lac.%d cid.%d pdp.%d\n",
        stat, lac, ci, bActiveContext);
    NU_LOG(buf);
#endif /* _VM_DEBUG */
}
/* redefined!!!
static  void rAT_PlusCGCMOD           ( void )
{
}
*/


struct TAPI_RESPONSE_TBL  s_NucleusACI_RESPONSE =  {
     rAT_OK,
     rAT_NO_CARRIER,
     rAT_CONNECT,
     rAT_BUSY,
     rAT_NO_ANSWER,
     rAT_PlusCME,
     rAT_PlusCMS,
     rAT_PlusCOPS,
     rAT_PlusCPIN,
     rAT_PlusCREG,
     rAT_PercentCREG,
     rAT_PlusCRING,
     rAT_PlusCRING_OFF,
#ifdef NO_ASCIIZ
     rAT_PlusCLIP,
#else  /* ifdef NO_ASCIIZ */
     rAT_PlusCLIP,
#endif /* ifdef NO_ASCIIZ */

     rAT_PlusCDIP,
     rAT_PlusCLIR,
#ifdef NO_ASCIIZ
     rAT_PlusCOLP,
#else  /* ifdef NO_ASCIIZ */
     rAT_PlusCOLP,
#endif /* ifdef NO_ASCIIZ */
     rAT_PlusDR,
     rAT_PlusCR,
     rAT_PlusCLCK,
     rAT_PlusCCFC,
#ifdef NO_ASCIIZ
     rAT_PlusCCWA,
#else  /* ifdef NO_ASCIIZ */
     rAT_PlusCCWA,
#endif /* ifdef NO_ASCIIZ */
     rAT_PlusCSMS,
     rAT_PlusCPMS,
     rAT_PlusCBMI,
     rAT_PlusCMT,
     rAT_PlusCMTPdu,
     rAT_PlusCMTI,
     rAT_PlusCMGS,

     rAT_PercentCMGRS,
     rAT_PlusCMSS,
     rAT_PlusCMGW,
     rAT_PlusCMGC,
     rAT_PlusCDS,
     rAT_PlusCDSPdu,


     rAT_PlusCBM,
     rAT_PlusCBMPdu,
     rAT_PlusILRR,
     rAT_PlusCMGR,
     rAT_PecentCMGRPdu,
     rAT_PlusCMGD,
     rAT_PlusCMGL,
     rAT_PecentCMGLPdu,
     rAT_PlusCUSD,
     rAT_PlusCCCM,
     rAT_PlusCSSI,
     rAT_PlusCSSU,
     rAT_PercentCCCN,
     rAT_PercentCSSN,
     rAT_PlusCPOL,
     rAT_PlusCLAN,
     rAT_PlusCLAE,

#ifdef TI_UMTS
     rAT_PercentCSQ,
#else
     rAT_PercentCSQ,
#endif

     rAT_PlusCIMI,
     rAT_PlusCNUM,
     rAT_PlusCRSM,
     rAT_PlusCSIM,
     rAT_PlusCGCMOD,
     rAT_PlusCCWV,
     rAT_PercentSQ,
     rAT_PercentBC,
     rAT_PercentDRV,
     rAT_PercentSIMREM,
     rAT_PercentSIMINS,
     rAT_PercentCOLR,
     rAT_PercentCLOG,
     rAT_PercentKSIR,
     rAT_PercentCPI,
     rAT_PercentCSTAT,
     rAT_PercentCPRSM,
     rAT_PercentALS,

     rAT_PercentCTYI,
     rAT_PercentCTV,
#if defined SIM_TOOLKIT || defined (TI_PS_FF_TRANSPARENT_SAT)
     rAT_PercentSATI,
     rAT_PercentSATE,
#endif /* SIM_TOOLKIT or TI_PS_FF_TRANSPARENT_SAT */
#ifdef SIM_TOOLKIT
     rAT_PercentSATN,
#ifdef TI_PS_FF_SATE
     rAT_PercentSATA,
     rCI_PercentSATT,
#else
     rAT_PercentSATA,
#endif /* TI_PS_FF_SATE */
     rAT_PercentSATT,

     rAT_SatFUN,
     rAT_SatFRN,

#endif  /* SIM_TOOLKIT */
     rAT_PercentCCBS,
     rAT_PercentCNAP,
     rAT_PlusCTZV,

     rAT_PercentCTZV,
     rAT_PercentCNIV,

     rAT_SignalSMS,

     rAT_phb_status,
     rAT_sms_ready,

     rAT_PlusCIEV,
     rAT_PlusCKEV,
     rAT_PercentCPKY,

#ifdef TI_PS_FF_EM
     rAT_PercentEINFO,
     rAT_PercentESINFO,
#endif /* TI_PS_FF_EM */

     rAT_PercentRDL,
     rAT_PercentRDLB,

#ifdef FF_GPS
     rAT_PercentGPSN,
     rAT_PercentGPSR,
#endif

     rAT_PercentCPRI,

#if defined(TI_UMTS) && defined(TI_PS_3GPP_R5)
     rAT_PercentMMCI,
#endif /* TI_UMTS && TI_PS_3GPP_R5 */

     rAT_PercentSIMEF,

     rAT_PlusCLVL,
     rAT_PlusCMUT,
     rAT_PlusCRSL,

     rAT_PercentCMGR,

     rAT_PercentCMGL,


     rBAT_PlusCMGL,

     rBAT_PercentCMGR,

#ifdef TI_PS_FF_EM
     rBAT_PercentEINFO,
     rBAT_PercentESINFO,
#endif /* TI_PS_FF_EM */

     rAT_PlusPACSP,

#ifdef TI_PS_3GPP_R5
     rAT_PercentMBI,
     rAT_PercentMBDN,
     rAT_PercentMWIS,
     rAT_PercentCFIS,
     rAT_PercentMWI,
#endif

     rAT_PercentCAUSE,
     rAT_PercentRLOG,

     rAT_PlusCGACT,
     rAT_PlusCGDATA,
     rAT_PlusCGANS,
     rAT_PlusCGEREP,
     rAT_PlusCGREG,
     rAT_changedQOS,
     rAT_PercentSNCNT,
     rAT_PercentCGREG,
    /*  rAT_PlusCGCMOD, redefined!!!*/
};


void init_ACI_response()
{
    nu_ACI_RegisterCallback(&s_NucleusACI_RESPONSE);
}

